package com.study.d012Components;

import java.net.URL;

/**
 *  Group上添加具体的组件
 *  Scene 中设置Group
 *  Stage 中设置 Scene
 */
import javafx.application.Application;
import javafx.application.HostServices;
import javafx.scene.Cursor;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class HostServicesMain extends Application{

	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		//加载本地资源 src下的资源
		URL url = getClass().getClassLoader().getResource("./icon/01.jpg");
		String path = url.toExternalForm();
		System.out.println(url);
		System.out.println(path);


		//打开网页
		HostServices hostServices = getHostServices();
		hostServices.showDocument("www.baidu.com");

		Button button = new Button("打印");
		button.setPrefWidth(100);
		button.setPrefHeight(100);
		//button上设置光标
		//button.setCursor(Cursor.HAND);

		//设置光标图片
		button.setCursor(Cursor.cursor(path));

		Group group = new Group();
		group.getChildren().add(button);

		Scene scene =new Scene(group);
		stage.setScene(scene);

		stage.setWidth(500);
		stage.setHeight(500);
		stage.show();

	}
}
